// 截取字符串指定长度
function toPureText(str, maxlength) {
  maxlength = maxlength || 40;
  str = (str || '').replace(/<[^>]+>|[\r\n]/gi, '');
  if (str.length > maxlength) {
    return str.substr(0, maxlength) + '...'
  } else {
    return str
  }
}

/**
 * @description 获取所有img标签的src
 * @param {*} html 
 */
function getAllImgSrc(html) {
  const regex = /<img\b[^>]*?src\s*=\s*["']?([^"'\s>]+)/gi;
  const matches = html.matchAll(regex);
  const res = Array.from(matches, m => m[1]);
  return res
}



export {
  toPureText,
  getAllImgSrc,

}